<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Question extends Model
{
    protected $fillable = [
        'cate_id','user_id','title','content','kiss','desc'
    ];
    public function cate()
    {
        return $this->belongsTo('App\Cate');
    }
    public function user()
    {
        return $this->belongsTo('App\User');
    }
    public function answers()
    {
        return $this->hasMany('App\Answer');
    }

    public function collects()
    {
        return $this->hasMany('App\Collect');
    }
    public function oneCollect($user_id)
    {
        return $this->collects()->where('user_id',$user_id);
    }
}
